package com.yanfan.ccapi.service.impl;

import com.yanfan.ccapi.service.ICcapiThirdPartyClientService;
import com.yanfan.ccapicode.dao.ThirdPartyClientRepository;
import com.yanfan.ccapicode.dao.entity.ThirdPartyClientDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 云云对接客户端Service业务层处理
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@Service
public class CcapiThirdPartyClientServiceImpl implements ICcapiThirdPartyClientService {
    @Autowired
    private ThirdPartyClientRepository ccapiThirdPartyClientMapper;

    /**
     * 查询云云对接客户端
     *
     * @param clientId 云云对接客户端主键
     * @return 云云对接客户端
     */
    @Override
    public ThirdPartyClientDO selectCcapiThirdPartyClientByClientId(String clientId) {
        return ccapiThirdPartyClientMapper.selectById(clientId);
    }

    /**
     * 查询云云对接客户端列表
     *
     * @param ccapiThirdPartyClient 云云对接客户端
     * @return 云云对接客户端
     */
    @Override
    public List<ThirdPartyClientDO> selectCcapiThirdPartyClientList(ThirdPartyClientDO ccapiThirdPartyClient) {
        return ccapiThirdPartyClientMapper.selectByCon(ccapiThirdPartyClient);
    }

    /**
     * 新增云云对接客户端
     *
     * @param ccapiThirdPartyClient 云云对接客户端
     * @return 结果
     */
    @Override
    public boolean insertCcapiThirdPartyClient(ThirdPartyClientDO ccapiThirdPartyClient) {
        ccapiThirdPartyClient.setCreateTime(LocalDateTime.now());
        return ccapiThirdPartyClientMapper.insertOrUpdate(ccapiThirdPartyClient);
    }

    /**
     * 修改云云对接客户端
     *
     * @param ccapiThirdPartyClient 云云对接客户端
     * @return 结果
     */
    @Override
    public boolean updateCcapiThirdPartyClient(ThirdPartyClientDO ccapiThirdPartyClient) {
        ccapiThirdPartyClient.setUpdateTime(LocalDateTime.now());
        return ccapiThirdPartyClientMapper.insertOrUpdate(ccapiThirdPartyClient);
    }

    /**
     * 批量删除云云对接客户端
     *
     * @param clientIds 需要删除的云云对接客户端主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiThirdPartyClientByClientIds(String[] clientIds) {
        return ccapiThirdPartyClientMapper.deleteByIds(Arrays.asList(clientIds));
    }

    /**
     * 删除云云对接客户端信息
     *
     * @param clientId 云云对接客户端主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiThirdPartyClientByClientId(String clientId) {
        return ccapiThirdPartyClientMapper.deleteById(clientId);
    }
}
